<?php

/**
 * 分页查询
*/

    include '../public/db_object.php';

    //echo "<pre>";
   // var_dump($_GET);

    // 当前页码
    $page = $_GET['page'];
    // 每页几条数据
    $limit = $_GET['limit'];
    $table = $_GET['table'];
    @$id = $_GET['id'];
    if(empty($id)){
        $sql = "select * from ".$table." limit ".($page - 1) * $limit.','. $limit;
    }else{
        $sql = "select * from ".$table." order by ".$id." desc limit ".($page - 1) * $limit.','. $limit;
    }
    
    

    $db = new DB_object(['db_name'=> 'db_shop']);
    $data = $db->l_select_all($sql);

    $data_echo = ["code"=>0, "msg"=>"", "count"=>1000, "data"=>$data];

 
    echo json_encode($data_echo);


?>